//
//  MemberSystemSettingController.m
//  yameishe3
//
//  Created by pro on 2017/3/3.
//  Copyright © 2017年 yameishe. All rights reserved.
//

#import "MemberSystemSettingController.h"
#import "MemberInfoController.h"
#import "AccountSafelyController.h"
#import "LoginViewController.h"
#import "YMSMemberManager.h"
@interface MemberSystemSettingController ()

@end

@implementation MemberSystemSettingController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)viewWillDisappear:(BOOL)animated {
    // 反注册键盘
    [super viewWillDisappear:YES];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(IBAction)onTouchButton:(UIButton *)sender
{
    switch (sender.tag) {
        case 0:
        {
            NSLog(@"个人资料");
            MemberInfoController *vc = [[UIStoryboard storyboardWithName:@"Member" bundle:nil] instantiateViewControllerWithIdentifier:@"MemberInfoController"];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1:
        {
            NSLog(@"账户安全");
          
            AccountSafelyController *vc = [[UIStoryboard storyboardWithName:@"Member" bundle:nil] instantiateViewControllerWithIdentifier:@"AccountSafelyController"];
            [self.navigationController pushViewController:vc animated:YES];
            
        }
            break;
        case 2:
        {
            NSLog(@"修改密码");
        }
            break;
        case 3:
        {
            NSLog(@"退出登录");
            YMSMember *member=[YMSMember loginMember];
            NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
            
            [dic setValue:[YMSMember loginMember].token forKey:@"_token"];
            if (member) {//退出登录后直接跳到登录页面
                [[YMSMemberManager alloc] MemberLogoutWithDic:dic successBlock:^(NSDictionary *result) {
                    UIStoryboard *main = [UIStoryboard storyboardWithName:@"LoginViewController" bundle:nil];
                    LoginViewController *loginVc = [main instantiateInitialViewController];
                    [UIApplication sharedApplication].keyWindow.rootViewController = loginVc;
                    [YMSMember setLoginMember:nil];
                    [YMSMember saveLoginMember];
                } failureBlock:^(NSString *error) {
                    
                }];
//                [[ASKMemberManager sharedInstance]desLoginWithToken:member.token successBlock:^{
//                    MyLog(@"退出登录成功");
//                    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//                    [delegate unbindAlias:[NSString stringWithFormat:@"%@",member.userid]];
//                    [self.navigationController popToRootViewControllerAnimated:YES];
//                    [ASKMember setLoginMember:nil];
//                } failureBlock:^(NSString *error) {
//                    MyLog(@"退出登录失败");
//                }];
            }

        }
            break;
        default:
            break;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
